package com.ruoyi.binance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.binance.domain.BinanceDailyMarket;
import com.ruoyi.binance.service.IBinanceDailyMarketService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日行情Controller
 * 
 * @author zq
 * @date 2025-09-10
 */
@RestController
@RequestMapping("/binance/market")
public class BinanceDailyMarketController extends BaseController
{
    @Autowired
    private IBinanceDailyMarketService binanceDailyMarketService;

    /**
     * 查询日行情列表
     */
    @PreAuthorize("@ss.hasPermi('binance:market:list')")
    @GetMapping("/list")
    public TableDataInfo list(BinanceDailyMarket binanceDailyMarket)
    {
        startPage();
        List<BinanceDailyMarket> list = binanceDailyMarketService.selectBinanceDailyMarketList(binanceDailyMarket);
        return getDataTable(list);
    }

    /**
     * 导出日行情列表
     */
    @PreAuthorize("@ss.hasPermi('binance:market:export')")
    @Log(title = "日行情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BinanceDailyMarket binanceDailyMarket)
    {
        List<BinanceDailyMarket> list = binanceDailyMarketService.selectBinanceDailyMarketList(binanceDailyMarket);
        ExcelUtil<BinanceDailyMarket> util = new ExcelUtil<BinanceDailyMarket>(BinanceDailyMarket.class);
        util.exportExcel(response, list, "日行情数据");
    }

    /**
     * 新增日行情
     */
    @PreAuthorize("@ss.hasPermi('binance:market:add')")
    @Log(title = "日行情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BinanceDailyMarket binanceDailyMarket)
    {
        return toAjax(binanceDailyMarketService.insertBinanceDailyMarket(binanceDailyMarket));
    }

    /**
     * 修改日行情
     */
    @PreAuthorize("@ss.hasPermi('binance:market:edit')")
    @Log(title = "日行情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BinanceDailyMarket binanceDailyMarket)
    {
        return toAjax(binanceDailyMarketService.updateBinanceDailyMarket(binanceDailyMarket));
    }

    /**
     * 删除日行情
     */
    @PreAuthorize("@ss.hasPermi('binance:market:remove')")
    @Log(title = "日行情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{codes}")
    public AjaxResult remove(@PathVariable String[] codes)
    {
        return toAjax(binanceDailyMarketService.deleteBinanceDailyMarketByCodes(codes));
    }
}
